{extend name="public/layout" /}
{block name="head"}{/block}
{block name="body"}
<body>
<div class="container-fluid p-t-15">
  <div class="card">
    <div class="card-header">
      <h4>修改视频信息</h4>
    </div>
    <div class="card-body">
      <form class="form-horizontal" id="form" data-url="/system/vod.index/index.html">
        <input type="hidden" name="FileId" value="{$Request.param.id}"/>
        <div class="form-group">
          <label class="col-sm-2 control-label">封面</label>
          <div class="col-sm-6 form-control-static">
            <input type="file" style="display:none;" id="cover-file" accept="image/png,image/gif,image/jpeg,image/jpg"/>
            <input type="hidden" name="CoverData" id="cover-data" value=""/>
            <div class="pull-left">
              <img id="cover-url" src="{$info.CoverUrl}" style="width:160px;height:90px;"/>
            </div>
            <div class="pull-left m-l-10">
              <button type="button" class="btn btn-default" onclick="$('#cover-file').click();">
                <i class="mdi mdi-image-album"></i> 更换封面
              </button>
              <button type="button" class="btn btn-default" id="restore-cover">
                <i class="mdi mdi-restore"></i> 还原封面
              </button>
              <p class="help-block">
                限JPG、PNG和静态GIF格式；文件名不得含有中文字符<br/>
                大小不超过1MB，尺寸不超过1920 x 1080；
              </p>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">名称</label>
          <div class="col-sm-6">
            {:\\helper\\Form::_text('Name',$info.Name,[
            "datatype"=>"*"
            ])}
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">描述</label>
          <div class="col-sm-6">
            {:\\helper\\Form::_textarea('Description',$info.Description)}
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 col- control-label">分类</label>
          <div class="col-sm-6">
            {:\\helper\\Form::_select('ClassId',$info.ClassId,[
            "empty-option"=>"-1|===未分类===",
            "items-data"=>$cate,
            "items-key"=>"id",
            "items-name"=>"_name"
            ])}
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">标签</label>
          <div class="col-sm-6">
            {:\\helper\\Form::_hidden('TagSet',$info.TagSet)}
            {:\\helper\\Form::_tags('AddTags',$info.TagSet)}
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">Vid</label>
          <div class="col-sm-6">
            <p class="form-control-static">{$info.Vid}
            </p>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">时长</label>
          <div class="col-sm-6">
            <p class="form-control-static">{:\\helper\\Utils::secToTime($info.Duration)}</p>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">文件类型</label>
          <div class="col-sm-6">
            <p class="form-control-static">{$info.Type}</p>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">原片大小</label>
          <div class="col-sm-6">
            <p class="form-control-static">
              {:\\helper\\Files::byteFormat($info.Size)}
              <span class="text-primary">[{$info.Width}×{$info.Height}]</span>
            </p>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">创建时间</label>
          <div class="col-sm-6">
            <p class="form-control-static">{$info.CreateTime}</p>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">更新时间</label>
          <div class="col-sm-6">
            <p class="form-control-static">{$info.UpdateTime}</p>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-10 col-sm-offset-2">
            <div class="pull-left">
              <button type="button" class="btn btn-primary btn-sub">保存</button>
              <button type="button" class="btn btn-default btn-reset">重置</button>
            </div>
            <div class="pull-left m-l-15">
              <p class="error-msg"></p>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
  formHelper.init();
  formHelper.subForm();
  //更换封面
  Do('lrz', function () {
    $('#cover-file').change(function (e) {
      var file = e.target.files || e.dataTransfer.files;
      lrz(file[0], {width: 1440, quality: 0.8}).then(function (rst) {
        $('#cover-data').val(rst.base64);
        $('#cover-url').attr('src',rst.base64);
      });
    });
  });
  $('#restore-cover').click(function () {
    var coverUrl = "{$info.CoverUrl}";
    $('#cover-data').val('');
    $('#cover-url').attr('src',coverUrl);
  });
</script>
</body>
{/block}